﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Collections;

namespace CDTM.Modules.TraCuuDiem.Components
{
    public partial class TotNghiep
    {
        public static List<TotNghiep> Clean(List<TotNghiep> list)
        {
            List<TotNghiep> newList = new List<TotNghiep>();

            var removeList = from item in list where item.MaSV != "" select item;

            foreach (TotNghiep obj in removeList)
            {
                newList.Add(obj);
            }

            return newList;
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteAll()
        {
            return DeleteDynamic("1=1");
        }

        //---------------------------------------------------------------------------------------------

        //public static int DeleteDynamic(string whereCondition)
        //{
        //    const string spName = "[dbo].[p_CDTM_TCD_TotNghiep_DeleteDynamic]";
        //    SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
        //    SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

        //    db.AddInParameter(dbCommand, "@WhereCondition", SqlDbType.Text, whereCondition);

        //    return db.ExecuteNonQuery(dbCommand);
        //}

        //---------------------------------------------------------------------------------------------

        public static int DeleteAllBy(int heDaoTaoID, int namHocID, string tenLop)
        {
            string where = string.Format("HeDaoTaoID = {0} AND NamHocID= {1} AND Lop = '{2}'",
                heDaoTaoID, namHocID, tenLop);

            return RenLuyen.DeleteDynamic(where);
        }
    }
}
